import { getMVURL, getMVDetail, getRelatedVideo } from '../../service/api/video'

Page({
  data: {
    mvURLInfo: {},
    mvDetail: {},
    relatedVideos: []
  },
  onLoad(options) {
    //1.获取页面跳转传入的id
    const id = options.id
    //2.获取页面的数据
    this.getPageData(id)
  },
  getPageData(id) {
    //为什么此处不使用 async+await？
    //因为await会让三个请求同步发出去，效率低
    //1.请求播放地址
    getMVURL(id).then(res => this.setData({ mvURLInfo: res.data }))
    //2.请求视频信息
    getMVDetail(id).then(res => this.setData({ mvDetail: res.data }))
    //3.请求相关视频
    getRelatedVideo(id).then(res => this.setData({ relatedVideos: res.data }))
  }
});